<template>
  <div class="cardContainer">
    <!-- <div class="subscribe">
      <el-button size="mini" @click.native="Subscribe(cardData)" style="transform:scale(0.6,0.6);">
        <i :class="[ cardData.subscribeid? 'el-icon-star-on': 'el-icon-star-off' ] "></i>
      </el-button>
    </div> -->
    <div class="cardLeft">
      <img v-if="cardData.cetAppicon !==''" :src="imgUrl" alt="图片载入失败">
      <img v-else src="../../../assets/img/appLogo.png" alt="图片载入失败，请升级浏览器">
    </div>
    <div class="cardRight">
      <div class="cardTitle" :title="cardData.cetAppname">{{ cardData.cetAppname }}</div>
    </div>
    <div style="clear:both;"/>
  </div>
</template>

<script>
import { editAppSubscribe } from "@/api/home";
export default {
  props: {
    cardData: {
      cetAppname: "",
      describe: "",
      cetAppicon: +""
    }
  },
  data() {
    return {
      imgUrl: ""
    };
  },
  watch: {
    cardData: {
      handler(newName, oldName) {
        this.imgUrl = this.IMG_URL + this.cardData.cetAppicon;
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    hrefTo() {},
    Subscribe(appId) {
      // 订阅动作
      // cardData.subscribeid
      editAppSubscribe(appId.id).then(res => {
        if (res.type === "add") {
          this.cardData.subscribeid = 0;
        } else {
          this.cardData.subscribeid = 1;
        }
        this.$notify({
          title: "成功",
          message: res.msg,
          type: "success",
          offset: 100
        });
      });
      return false;
    }
  }
};
</script>

<style lang="scss" scoped>
$cardImgH: 40px;
.cardContainer {
  width: 200px;
  height: auto;
  padding: 14px;
  margin: 10px 0;
  cursor: pointer;
    border: 1px solid #e8e8e8;
  position: relative;
  .subscribe {
    width: auto;
    position: absolute;
    right: -9px;
    top: -7px;
  }
  .cardLeft {
    width: $cardImgH;
    height: $cardImgH;
    float: left;
    img {
      width: $cardImgH;
      height: $cardImgH;
      border-radius: 50%;
    }
  }
  .cardRight {
    margin-left: 60px;
    .cardTitle {
      height: 24px;
      line-height: 24px;
      font-size: 14px;
      font-weight: 400;
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
      cursor: pointer;
    }
    .cardDesc {
      font-size: 12px;
      color: #e8e8e8;
      cursor: pointer;
      div {
        width: auto;
        max-width: 30%;
        height: 20px;
        line-height: 20px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        float: left;
      }
    }
  }
}
</style>
